//
//  JMPublicAlertView.h
//  NewiOSProject
//
//  Created by MAC on 2023/9/1.
//  Copyright © 2023 范智渊. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <YYText.h>
#import "JMLoadingButton.h"
typedef NS_ENUM(NSInteger, JMPublicAlertViewPosition) {
    JMPublicAlertViewPositionCenter,
    JMPublicAlertViewPositionBottom,
};
typedef NS_ENUM(NSInteger, JMPublicAlertViewButtonDirection) {
    JMPublicAlertViewButtonDirectionHor,
    JMPublicAlertViewButtonDirectionVer,
};


NS_ASSUME_NONNULL_BEGIN
@protocol JMPublicAlertViewDelegate<NSObject>

- (void)didClickBtnAtIndex:(NSInteger)index withButton:(JMLoadingButton *)sender;

@optional
- (void)closeBtnDidClick;

- (void)coverViewDidClick;
@end






@interface JMPublicAlertView : UIView

@property (nonatomic,weak)id<JMPublicAlertViewDelegate>delegate;

@property(nonatomic)UIButton *closeBtn;

//点击空白是否能消失
@property(nonatomic,assign)BOOL canDismiss;
//是否需要操作按钮是否需要loading
@property(nonatomic,assign)BOOL buttonNeedLoading;
//大标题
@property(nonatomic)UILabel *titleLab;
//小标题
@property(nonatomic)UILabel *subtitleLab;
//底部操作按钮
@property(nonatomic)JMLoadingButton *firstBtn,*secondBtn;
//顶部image
@property(nonatomic)UIImageView *topImgV;


-(instancetype)initWithFrame:(CGRect)frame
                    andTitle:(NSString *)title
                    subTitle:(NSString *)subTitle
                  BottomBtns:(NSArray *)btnTitles
                    Position:(JMPublicAlertViewPosition)position
                btnDirection:(JMPublicAlertViewButtonDirection)direction;
/// 工厂方法
/// - Parameters:
///   - btnTitles: 底部按钮的标题
///   - title: 顶部大标题
///   - subTitle: 顶部小标题
///   - position: 弹窗弹出位置 （中心/底部）
///   - direction: 按钮排列方向（左右/上下）
///
+(instancetype)showAlertWithFrame:(CGRect)frame
                    Title:(NSString *)title
                 subTitle:(NSString *)subTitle
               BottomBtns:(NSArray *)btnTitles
                 Position:(JMPublicAlertViewPosition)position
             btnDirection:(JMPublicAlertViewButtonDirection)direction
           btnActionBlock:(void(^)(NSInteger btnTag))actionBlock;

-(void)show;
-(void)dismiss;
@end

NS_ASSUME_NONNULL_END
